<include file="Common:minheader" />
<!-- /. NAV SIDE  -->
<form class="layui-form" action="">
	<input type="hidden" name="id" value="{$info.id}">
	<div class="layui-form-item">
		<label class="layui-form-label">名称</label>
		<div class="layui-input-block">
		  <input value="{$info.title}" type="text" required  lay-verify="required" placeholder="请输入课程名称" autocomplete="off" class="layui-input" disabled="true">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">所属教练</label>
		<div class="layui-input-block">
			<select lay-verify="required" lay-search="" disabled="true">
				<option value="">请选择</option>
				<notempty name="coachList">
					<volist name="coachList" id="vo" key="key">
						<option value="{$vo.id}" <if condition="$info['coach_id'] eq $vo['id']">selected</if>>{$vo.name}</option>
					</volist>
				</notempty>
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">约课会员</label>
		<div class="layui-input-block">
			<select name="user_id" lay-verify="required" lay-search>
				<option value="">请选择</option>
				<notempty name="userList">
					<volist name="userList" id="vo" key="key">
						<option value="{$vo.id}" <if condition="$info['cate_id'] eq $vo['id']">selected</if>>{$vo.username}({$vo.mobile})</option>
					</volist>
				</notempty>
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">次数</label>
		<div class="layui-input-block">
		  <input name="nums" value="1" type="text" required  lay-verify="required" placeholder="请输入次数" autocomplete="off" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
          <textarea name="memo" placeholder="请输入备注" class="layui-textarea"></textarea>
        </div>
    </div>
	<div class="layui-form-item">
		<div class="layui-input-block">
		  <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
		  <button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
  </div>
</form>
<script>
	//Demo
	layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function(data){
        	var cont = data.field;
        	$.ajax({
        		url:"{:U('Course/addUserCourse')}",
        		type:'post',
        		dataType:'json',
        		data:cont,
        		success:function(data){
        			if(data.code==0){
        				layer.alert(data.message);
        			}else{
        				layer.alert(data.message, function(index){
        					//do something
        					window.parent.location.reload();
        					var index = parent.layer.getFrameIndex(window.name); 
        					parent.layer.close(index);
        				});
        			}
        		}
        	});
        	//layer.msg(JSON.stringify(data.field));
        	return false;
        });
});
</script>
<!-- /. PAGE INNER  -->
<include file="Common:footer" />